package net.skycloud.f5.error;

/**
 * Created by work on 2017/5/31.
 * http response error code enumeration
 */
public enum ErrorCode {
    // db item
    NOT_SUCH_OBJECT("000001", "No such Object"),
    OBJECT_CONFLICT("000002", "Object conflict"),
    // param
    INPUT_ERROR("001000", "Input fields are illegal, please check."),
    PARAM_CHECK_FAILED("001001", "Param check failed"),
    PASSWORD_CHECK_FAILED("001002", "Wrong password"),
    NAT_AUTOFILL_FAILED("001003", "Nat autofill failed"),
    NAT_AUTOFILL_INPUT_SUGGESTION("001004", "Nat autofill input suggestion"),
    NAT_AUTOFILL_INPUT_CHECK_FAILED("001005", "Autofill can not input Nat address"),
    // db
    DATABASE_OP_FAILED("002001", "Database operations failed"),
    // jwt
    JWT_TOKEN_ERROR("003001", "Errors related with jwt token"),
    AUTHENTICATION_FAILED("003002", "Username or password error"),

    // json serialize/deserialize
    SERIALIZE_JSON_ERROR("004001", "Serialize json error"),

    // device lock
    DEVICE_LOCK_OP_FAILED("005001", "Lock device failed"),

    DEVICE_CONNECT_ERROR("005002", "device connect fail error"),

    DEVICE_PULL_ERROR("005003", "device pull fail error"),

    DEVICE_UN_SUPPORTED("005004", "device vendor or type Unsupported"),

    // quartz error
    QUARTZ_OP_ERROR("006001", "job system operation error"),

    //EMAIL
    EMAIL_ERROR("007001", "email send error"),
    EMAIL_SERVER_NOT_SET_ERROR("007001", "email server not set"),

    // PIPELINE
    PIPE_RUN_ERROR("008001", "run pipeline error"),
    PIPE_RUN_STEP_ERROR("008002", "run pipeline step error"),

    // LICENSE
    //LICENCE DECRYPT
    LICENCE_DECRYPT_ERROR("009001", "decrypt license error"),

    //LICENCE VALIDATE
    LICENCE_VALIDATE_ERROR("009002", "validate license error"),

    //LICENCE EXPIRED
    LICENCE_EXPIRE_ERROR("009003", "license expired error"),

    // rpc
    RPC_REQUEST_ERROR("010001", "do rpc request failed"),

    // vendor2vm or vm2vendor
    VENDOR_TO_VM_ERROR("011001", "vendor2vm failed"),

    // deserialize errors
    DESERIALIZE_FAIL_ERROR("012001", "deserialize failed"),

    //NSX-tT errors
    CREATE_NSXT_RULE_ERROR("000701", "create NSX-T rule failed"),
    CREATE_NSXT_SECTION_ERROR("000702", "create NSX-T section failed"),
    NSXT_OP_ERROR("000703", "NSX-T operations failed"),
    //clearAclHitCount error
    CLEAR_ACL_HIT_COUNT_ERROR("013001", "clear acl hitcount failed"),

    //OPT Automatic error
    OPT_AUTOMATIC_ERROR("0000070","opt device automatic error"),

    //Analyze error
    ANALYZE_ERROR("00000077","policy analyze failed"),
    //CheckPoint errors
    CHECKPOINT_OP_ERROR("000803", "CheckPoint operations failed"),

    KEYCLOAK_API_ERROR("000901", "Keycloak API operations error"),
    //network error
    NETWORK_CONNECT_ERROR("0000044", "failed: Connection timed out: connect"),
    // undefined error
    UNDEFINED_ERROR("999999", "undefined error");


    private String errorCode;
    private String description;

    ErrorCode(String errorCode, String description) {
        this.errorCode = errorCode;
        this.description = description;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "ErrorCode{" +
                "errorCode='" + errorCode + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}
